This is a catch-all used by many Delorme mapping products and
reads the anr, rte, and rtd formats as either tracks or routes.
+
+ The 'turns_only' option causes GPSBabel to read only the waypoints
+ associated with named turns. This should create a list of waypoints
+ that correspond to the itinerary from Street Atlas.
+ The 'turns_important' option only makes sense in conjunction with
+ the 'simplify' filter. It ensures that the route simplification
+ process will remove the points corresponding to turns only after
+ it has removed all other route points.
+
+ Both options only apply to route files from newer versions of
+ DeLorme software; older versions didn't store the turn information
+ with the route.
+
saplus
This format is for Street Atlas USA 2004 Plus.
const char *icon_descr;
time_t creation_time; /* standardized in UTC/GMT */
int centiseconds; /* Optional hundredths of a second. */
+
+ /*
+ * route priority is for use by the simplify filter. If we have
+ * some reason to believe that the route point is more important,
+ * we can give it a higher (numerically; 0 is the lowest) priority.
+ * This causes it to be removed last.
+ * This is currently used by the saroute input filter to give named
+ * waypoints (representing turns) a higher priority.
+ */
+ int route_priority;
+
geocache_data gc_data;
xml_tag *gpx_extras;
void *extra_data; /* Extra data added by, say, a filter. */
FILE *infile;
+char *turns_important = NULL;
+char *turns_only = NULL;
+
+static
+arglist_t saroute_args[] = {
+ {"turns_important", &turns_important,
+ "Keep turns if simplify filter is used", ARGTYPE_BOOL },
+ {"turns_only", &turns_only, "Only read turns; skip all other points",
+ ARGTYPE_BOOL },
+ {0, 0, 0, 0 }
+};
+
unsigned short
ReadShort(FILE * f)
{
wpt_tmp->latitude = lat;
wpt_tmp->longitude = -lon;
wpt_tmp->shortname = (char *) xmalloc(7);
+ if ( turns_important && stringlen )
+ wpt_tmp->route_priority=1;
sprintf( wpt_tmp->shortname, "\\%5.5x",
serial++ );
- route_add_wpt(track_head, wpt_tmp);
+ if ( !turns_only || stringlen )
+ route_add_wpt(track_head, wpt_tmp);
latlon++;
coordcount--;
+ stringlen = 0;
+ /* the stop point is a "turn" */
+ if ( coordcount == 1 && count == 0 ) {
+ stringlen = 1;
+ }
}
xfree(record);
}
NULL,
my_read,
NULL,
- NULL
+ saroute_args
};
static
arglist_t routesimple_args[] = {
- {"count", &countopt, "Maximum number of points in final route",
+ {"count", &countopt, "Maximum number of points in route",
ARGTYPE_INT | ARGTYPE_REQUIRED},
{0, 0, 0, 0}
};
int
compare_xte( const void *a, const void *b )
{
- double foo = (((struct xte *)a)->distance - ((struct xte *)b)->distance );
- if ( foo < 0 ) return 1;
- if ( foo > 0 ) return -1;
+ double distdiff = ((struct xte *)a)->distance -
+ ((struct xte *)b)->distance;
+ int priodiff = ((struct xte *)a)->intermed->wpt->route_priority -
+ ((struct xte *)b)->intermed->wpt->route_priority;
+ if ( priodiff < 0 ) return 1;
+ if ( priodiff > 0 ) return -1;
+ if ( distdiff < 0 ) return 1;
+ if ( distdiff > 0 ) return -1;
return 0;
}
shuffle_xte( struct xte *xte_rec )
{
struct xte tmp_xte;
- while ( xte_rec > xte_recs &&
- xte_rec->distance > xte_rec[-1].distance ) {
+ while ( xte_rec > xte_recs && compare_xte(xte_rec, xte_rec-1) < 0 ) {
tmp_xte.distance = xte_rec->distance;
tmp_xte.ordinal = xte_rec->ordinal;
tmp_xte.intermed = xte_rec->intermed;
xte_rec->intermed->xte_rec = xte_rec;
}
while ( xte_rec - xte_recs < xte_count-2 &&
- xte_rec->distance < xte_rec[1].distance ) {
+ compare_xte( xte_rec, xte_rec+1) > 0 ) {
tmp_xte.distance = xte_rec->distance;
tmp_xte.ordinal = xte_rec->ordinal;
tmp_xte.intermed = xte_rec->intermed;